package model;

import android.support.annotation.NonNull;
import android.util.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * Created by lym on 2017/6/2.
 */

public class Alarm{
    private boolean a_isread;
    private int a_id;
    private String a_name;
    private Calendar a_time;
    private int u_id;
    private int t_id;
    private String a_detail;
    private boolean a_ispush;

    public Alarm(){}

    public Alarm(boolean a_isread, int a_id, String a_name, String a_time, int u_id, int t_id,String a_detail ,boolean a_ispush) throws ParseException {
        this.a_isread = a_isread;
        this.a_id = a_id;
        this.a_name = a_name;
        this.a_time = StringtoCalendar(a_time);
        this.u_id = u_id;
        this.t_id = t_id;
        this.a_detail = a_detail;
        this.a_ispush = a_ispush;
    }

    public String getA_detail() {
        return a_detail;
    }

    public void setA_detail(String a_detail) {
        this.a_detail = a_detail;
    }

    public boolean isA_ispush() {
        return a_ispush;
    }

    public void setA_ispush(boolean a_ispush) {
        this.a_ispush = a_ispush;
    }

    public int getU_id() {
        return u_id;
    }

    public void setU_id(int u_id) {
        this.u_id = u_id;
    }

    public int getT_id() {
        return t_id;
    }

    public void setT_id(int t_id) {
        this.t_id = t_id;
    }

    public String getA_name() {
        return a_name;
    }

    public void setA_name(String a_name) {
        this.a_name = a_name;
    }

    public boolean isA_isread() {
        return a_isread;
    }

    public void setA_isread(boolean a_isread) {
        this.a_isread = a_isread;
    }

    public int getA_id() {
        return a_id;
    }

    public void setA_id(int a_id) {
        this.a_id = a_id;
    }

    public Calendar getA_time() {
        return a_time;
    }

    public String getA_timeString() {
        return CalendartoString(this.a_time);
    }

    public void setA_time(Calendar a_time) {
        this.a_time = a_time;
    }

    /**
     * 日期转争字符串
     * @param date
     * @return
     */
    public String CalendartoString(Calendar date){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return  simpleDateFormat.format(date.getTime());
    }
    public Calendar StringtoCalendar(String date) throws ParseException {
        Calendar calendar = new GregorianCalendar();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        calendar.setTime(simpleDateFormat.parse(date));
        return  calendar;
    }

}
